﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PMC;

namespace PMCgui
{
    public partial class upgradeUsercontrol : UserControl
    {
        public upgradeUsercontrol()
        {
            InitializeComponent();
            Dock = DockStyle.Fill;
        }

        private void btnWebsite_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog { Filter = Language.Instance.PMCWebsiteFile + " | websites.ini|All files | *.*" };
            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    Upgrade.UpgradeWebsites(dialog.FileName, new OverrideConfirm()/*, "http://www.", ".nl"*/);
                }
                catch (Exception)
                {
                    MessageBox.Show(Language.Instance.ErrorOccured);
                }
            }
        }

        private void btnImportExpressions_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog { Filter = Language.Instance.PMCExpressionFile + " | exc.ini|All files | *.*" };
            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    Upgrade.UpgradeExpressions(dialog.FileName, new OverrideConfirm());
                }
                catch (Exception)
                {
                    MessageBox.Show(Language.Instance.ErrorOccured);
                }
            }
        }
    }
}
